|
Server : LiteSpeed System : Linux host 5.15.0-161-generic #171-Ubuntu SMP Sat Oct 11 08:17:01 UTC 2025 x86_64 User : idnco5810 ( 1093) PHP Version : 8.2.29 Disable Function : NONE Directory : /usr/local/CyberCP/cli/ |
Upload File : |
import subprocess
import time
class cliLogger:
fileName = "/home/cyberpanel/error-logs.txt"
@staticmethod
def writeforCLI(message, level, method):
try:
file = open(cliLogger.fileName, 'a')
file.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "] [" + level + ":" + method + "] " + message + "\n")
file.close()
file.close()
except IOError:
return "Can not write to error file!"
@staticmethod
def readLastNFiles(numberOfLines,fileName):
try:
lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName]).decode("utf-8")
return lastFewLines
except subprocess.CalledProcessError as msg:
return "File was empty"